#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		long long  a, b;
		cin >> a >> b;
		bool flag = 0;
		int mi = 100010;
		int ma = -1000010;
		for (int c = 2; c <= max(a, b); c++)	{
			if (a % c == b % c) {
				if (mi > c) {
					mi = c;
				}
				if (ma < c) {
					ma = c;
				}
				flag = 1;
			}
		}
		if (flag) {
			cout << mi << " " << ma << endl;
		}
		else {
			cout << "-1 -1" << endl;
		}
	}
	return 0;
}